import pandas as pd
import numpy as np

df = pd.DataFrame({
    "A": [12, 4, 5, None, 1],
    "B": [None, 2, 54, 3, None],
    "C": [20, 16, None, 3, 8],
    "D": [14, 3, None, None, 6]
})
print(df)
# 使用线性方法插值
df2 = df.interpolate(method='linear', limit_direction='forward')
print(df2)

df3 = df.interpolate(method='polynomial', order=2)
print(df3)
